package com.pxmeta.dynamic.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pxmeta.dynamic.entity.DynamicDislike;
import com.pxmeta.dynamic.mapper.DynamicDislikeMapper;
import com.pxmeta.dynamic.service.IDynamicDislikeService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wcl
 * @since 2022-07-14
 */
@Service
public class DynamicDislikeServiceImpl extends ServiceImpl<DynamicDislikeMapper, DynamicDislike> implements IDynamicDislikeService {

    @Override
    public List<Long> getDislikeDynamicIds(Long userId, Integer type) {
        LambdaQueryWrapper<DynamicDislike> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(DynamicDislike::getUserId, userId)
                .eq(DynamicDislike::getType, type);
        return this.list(wrapper).stream().map(DynamicDislike::getDynamicId).collect(Collectors.toList());
    }
}
